package cc.cc4414.cc03.core.webSocket;

import java.time.LocalDateTime;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cc.cc4414.cc03.chat.VO.MessageSendVO;
import cc.cc4414.cc03.chat.constant.MessageTypeConsts;
import cc.cc4414.cc03.core.controller.BaseController;
import cc.cc4414.cc03.core.util.JsonUtils;

/**
 * webSocket前端控制器
 * 
 * @author cc 2019年1月6日
 */
@RestController
@RequestMapping("/core/webSocket")
public class WebSocketController extends BaseController {

	/**
	 * 心跳检测
	 */
	@PostMapping("heartCheck")
	public void heartCheck(String content) {
		MessageSendVO messageSendVO = new MessageSendVO();
		messageSendVO.setType(MessageTypeConsts.HEART);
		messageSendVO.setContent(content);
		messageSendVO.setTime(LocalDateTime.now());
		WebSocket.sendMessage(JsonUtils.format(messageSendVO), getUser().getId());
	}

}
